window.onload=function () {
    var app = new Vue({
        el: "#app",
        data: {
            pagination: {
                total: 0, //总记录数
                pageSize: 10, //每页的记录数
                pageNum: 1, //当前页码
            },
            answerarray:[],//所有未审核文章
            lookanswerno:false,//控制查看未审核文章
            answer:{
                qid_no:"",//未审核问题回答id
                uid:"",//发布用户
                name:"",//发布用户
                a_title:"",//标题
                state:"",//状态
                reasons:"",//原因
                q_content:"",//内容
                tid:""//分配的牙齿类型
            },
            updateanswerbox:false,//控制修改未审核文章
            toucharray:[],//所以类型
            deletearticle:false,//删除弹出框,
            state:"",
            options:[{
                value:'1',
                label: '未审核'},
                {
                    value:'2',
                    label: '未通过'},
                {
                    value:'0',
                    label: '已删除'}
            ]
        },
        methods: {
            inisarticleno(){
                //初始化数据
                methodaxios.get(null,"/question/listno?currentPage="+this.pagination.pageNum+"&pageSize="+this.pagination.pageSize+"&state="+this.state,rep=>{
                    window.console.log("================================");
                    window.console.log(rep.data.data);
                    this.answerarray=rep.data.data;
                    this.pagination.total=rep.data.count;
                });
            },
            inittouch(){
                methodaxios.get(null,"/touch/listanswer",rep=>{
                    window.console.log(rep)
                    this.toucharray=rep.data
                });
            },//当前页发送改变
            findBlogPageList(page) {
                //页数改变
                this.pagination.pageNum = page;
                this.inisarticleno();
            }, //每页大小发送改变
            sizeChange(size) {
                this.pagination.pageSize = size; //当前页显示多少
                this.pagination.pageNum = 1;
                this.inisarticleno();
            },//点击搜索
            searchswer(){
                //this.pagination.pageSize = size; //当前页显示多少
                this.pagination.pageNum = 1;
                this.inisarticleno();
            },
            resetanswer(){
                this.state=""
               // this.pagination.pageSize = size; //当前页显示多少
                this.pagination.pageNum = 1;
                this.inisarticleno();
            },
            wantlookanswer(row){//查看当前问答
                var E = window.wangEditor
                var editor = new E('#editor')
                editor.create()
                this.lookanswerno=true
                this.answer.a_title=row.a_title;
                this.answer.name=row.name;
                editor.$textElem.attr('contenteditable', false)
                editor.txt.html('<p>' +row.q_content+'</p>' );
            },
            updateanswer(row){//点击修改问答
                this.answer.a_title=row.a_title;
                this.answer.qid_no=row.qid_no;
                this.answer.state=row.state;
                this.answer.q_content=row.q_content;
                this.answer.uid=row.uid;
                window.console.log("未审核问答")
                window.console.log(row)
                window.console.log(this.answer)
                this.updateanswerbox=true
                var E = window.wangEditor
                var editor = new E('#updateeditoranswer')
                editor.create()
                editor.$textElem.attr('contenteditable', false)
                editor.txt.html('<p>' +row.q_content+'</p>' );
            },
            confirmupdateaanswer(){//确定修改问答
                if(isBlank(this.answer.state)){
                    layer.msg("请指定状态");
                    return false;
                }
                if(isBlank(this.answer.reasons)){
                    layer.msg("请填写问答描述");
                    return false;
                }
                if(isBlank(this.answer.tid)){
                    layer.msg("请指定问答类型");
                    return false;
                }
                methodaxios.post("/question/updateno",this.answer,rep=>{
                    if(rep.data.code==="200"){
                        this.answer.tid=""
                        this.answer.reasons=""
                        this.answer.state=""
                        layer.msg("修改成功");
                        this.updateanswerbox=false
                        this.inisarticleno();
                    }
                });
            }


        },mounted(){
            this.inisarticleno();
            this.inittouch();
        },
        filters:{
            mytime(value){
                var dateee = new Date( value).toJSON();
                return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
            },//状态(0 伪删除 1审核中 2通过 3未通过)
            mystate(value){
                if(value=="0"){
                    return "已删除"
                }else if(value=="1"){
                    return "审核中"
                }else if(value=="2"){
                    return "未通过"
                }
            }
        }

    })
}
